#coding=UTF-8
from django.shortcuts import render,render_to_response
from django.http import HttpResponse
from models import Coats
import random
# Create your views here.
def index(req,id=1):
     d = generateRandomList(20,6)
     print d
     print d
     c = {
         #"data":[5, 20, 40, 10, 10, 100],
         "uname":"Echarts and Django"
         #"coats":getAllcoatnum()
          }
     id = int(id)

     if id >= len(d):
         id = len(d)

     print id
     c["data"]=d[id-1]
     return render_to_response("demo2.html",c)


def getAllcoatnum():
    allCoats = Coats.objects.all()
    nums = []
    for i in range(len(allCoats)):
        nums.append(int(allCoats[i].num))
    return nums

def generateRandomList(listLength,elemLength):
    d = []
    for i in range(listLength):
        print i
        a = [(x+1)*random.randint(1,100) for x in range(elemLength)]
        d.append(a)

    print d
    return d

if __name__ == "__main__":
    generateRandomList(5,6)


